clear all
set more off
capture log close
log using "$output/figure3.log", replace

version 16	

use "$data/ctctaxsim_mar1kid1.dta", clear
append using "$data/ctctaxsim_mar1kid2.dta"
append using "$data/ctctaxsim_mar1kid3.dta"

*** 2017 law
twoway line v25 earnings if year==2017 & depx==2 || line totctc earnings if year==2017 & depx==2, graphregion(color(white)) bgcolor(white) text(4.500 20.000 "EITC" , j(left) size(medsmall)) text(1.000 25.000 "CTC" , j(left) size(medsmall)) ylabel(0(4.000)12.000) leg(off) ytitle("Tax Credits ($1000s)") xtitle("Earnings ($1000s)" "{bf:Panel A: 2017 Policy}") text(11.500 80.000 "2017 Policy" , box fc(white) margin(small) j(left) size(medsmall))  || line taxesowed earnings if year==2017 & depx==2, yaxis(2) ylabel(0 "0" -4.000 "4" -8.000 "8" -12.000 "12", axis(2)) lp(-) text(6.500 75.000 "Income Tax" "(Right Axis)", j(left) size(medsmall)) ytitle("Income Taxes Owed ($1000s)", axis(2))
graph save "$output/ctceitc1_mar1kid2.gph", replace

*** 2018 law
twoway line v25 earnings if year==2018 & depx==2 || line totctc earnings if year==2018 & depx==2, graphregion(color(white)) bgcolor(white) text(4.500 20.000 "EITC" , j(left) size(medsmall)) text(1.600 24.000 "CTC" , j(left) size(medsmall)) ylabel(0(4.000)12.000) leg(off) ytitle("Tax Credits ($1000s)") xtitle("Earnings ($1000s)" "{bf:Panel B: 2020 Policy}") text(11.500 80.000 "2020 Policy" , box fc(white) margin(small) j(left) size(medsmall))  || line taxesowed earnings if year==2018 & depx==2, yaxis(2) ylabel(0 "0" -4.000 "4" -8.000 "8" -12.000 "12", axis(2)) lp(-) text(7.500 75.000 "Income Tax" "(Right Axis)", j(left) size(medsmall)) ytitle("Income Taxes Owed ($1000s)", axis(2))
graph save "$output/ctceitc2_mar1kid2.gph", replace

*** 2018 law
twoway line v25 earnings if year==2018 & depx==2 || line ctc2021 earnings if year==2018 & depx==2, graphregion(color(white)) bgcolor(white) text(4.500 20.000 "EITC" , j(left) size(medsmall)) text(6.900 29.000 "CTC" , j(left) size(medsmall)) ylabel(0(4.000)12.000) leg(off) ytitle("Tax Credits ($1000s)") xtitle("Earnings ($1000s)" "{bf:Panel C: 2021 Policy}") text(11.500 80.000 "2021 Policy" , box fc(white) margin(small) j(left) size(medsmall))  || line taxesowed earnings if year==2018 & depx==2, yaxis(2) ylabel(0 "0" -4.000 "4" -8.000 "8" -12.000 "12", axis(2)) lp(-) text(3.500 85.000 "Income Tax" "(Right Axis)", j(left) size(medsmall)) ytitle("Income Taxes Owed ($1000s)", axis(2))
graph save "$output/ctceitc3_mar1kid2.gph", replace

*** THIS COMPARES TAX CREDITS IN 2017, 2018, 2021
twoway line negfiitax earnings if year==2017 & depx==2, lp(-) pstyle(p1) || line negfiitax earnings if year==2018 & depx==2, lp(_) pstyle(p2) || line negfedtax2021 earnings if year==2018 & depx==2,  pstyle(p1) graphregion(color(white)) bgcolor(white) ylabel(-12.000(6.000)12.000) leg(order(1 "2017" 2 "2020" 3 "2021") c(1) pos(7) ring(0)) ytitle("Net Tax Credits ($1000s)") xtitle("Earnings" "{bf:Panel D: Net Effect from CTC, EITC, Income Tax}") text(9.00 75.000 "Net Tax Credits" "from EITC, CTC," "Income Taxes", box fc(white) margin(small) j(left) size(medsmall))
graph save "$output/ctceitc4_mar1kid2.gph", replace


graph combine "$output/ctceitc1_mar1kid2.gph" "$output/ctceitc2_mar1kid2.gph" "$output/ctceitc3_mar1kid2.gph" "$output/ctceitc4_mar1kid2.gph",graphregion(color(white))
graph export "$output/figure3.png", replace

erase "$output/ctceitc1_mar1kid2.gph" 
erase "$output/ctceitc2_mar1kid2.gph" 
erase "$output/ctceitc3_mar1kid2.gph" 
erase "$output/ctceitc4_mar1kid2.gph"

log close